<template>
	<div id="app" v-if="checked">
		<keep-alive>
			<router-view class="view-router" v-if="$route.meta.keepAlive"></router-view>
		</keep-alive>
		<router-view class="view-router" v-if="!$route.meta.keepAlive"></router-view>
		<keep-alive>
      <router-view name="tabbar"></router-view>
    </keep-alive>
	</div>
</template>

<script>
import { FIRST_INIT } from "@/api/global";

export default {
	data() {
		return {
			//校验账户结束
			checked: false,
		}
	},

	created() {
		const token = this.$util.getLocalStorage('authToken');
		if (token) {
			this.$reqGet(FIRST_INIT, {memberId: this.user.id}).then(res => {
				this.user = res.data.data;
				this.user.supplier = res.data.supplier;
				this.saveUser(this.user);
				//黑名单
				if (this.user.status === 9) {
					this.$router.replace({name: 'login-forbidden'});
				}

				if (res.data.shop) {
					this.saveShop(res.data.shop);
				}

				if (res.data.config) {
					this.$util.setSessionStorage("config", res.data.config);
				}
				window.serverTime = res.data.time;
				this.checked = true;
			}).catch(error => {
				if(error.data == undefined){
					
				}else{  //去登陆
					this.$util.removeStorage('authToken');
				 	this.$router.push({name: 'login'});
				}
				this.checked = true;
			});
		} else {
			this.checked = true;
		}
	}
}
</script>

<style lang="scss" src="@/assets/scss/global.scss" />
